<template>
	<view class="flex-col page">
		<view class="flex-col group_3">
			<image :src="$IMG_URL+'login/logo.png'" class="image_7" />
			<view class="flex-col group_4">
				<view class="flex-row group_ipt">
					<image :src="$IMG_URL+'16557826680563820686.png'" class="image_8 image_9" />
					<input type="number" placeholder="请输入手机号" v-model="phone">
				</view>
				<view style="width: 100%;height: 1px;background-color: #EEEEEE;margin-top: 40rpx;"></view>
				<view class="flex-col group_6">
					<image :src="$IMG_URL+'16557826684246479237.png'" class="image_10 image_11" />
					<view class="justify-between group_7">
						<view class="flex-row group_ipt">
							<image :src="$IMG_URL+'16557826687461271724.png'" class="image_8 image_12" />
							<input type="number" placeholder="请输入验证码" v-model="code">
						</view>
						<text v-if="showText==true" class="text_2" @click="getYZM">获取验证码</text>
						<view v-else class="send">{{second}}s重新发送</view>
					</view>
				</view>
				<view style="width: 100%;height: 1px;background-color: #EEEEEE;margin-top: 40rpx;"></view>
				<view class="justify-between group_9">
					<!-- <view class="flex-row group_ipt">
						<image :src="$IMG_URL+'16557826680563820686.png'" class="image_8 image_9" />
						<input type="number" placeholder="请输入手机号" v-model="phone">
					</view> -->
					<view class="flex-row group_ipt">
						<image :src="$IMG_URL+'16557826680099271215.png'" class="image_8 image_14" />
						<uni-easyinput type="password" v-model="password" placeholder="请输入密码(6~12位字母+数字)"
							style='width: 600rpx;margin-left: 2.5%;border: 0 none;'></uni-easyinput>
					</view>
				</view>
				<view style="width: 100%;height: 1px;background-color: #EEEEEE;"></view>
			</view>
			<view class="flex-col items-center button" @click="submit"><text class="text_4">确定</text></view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				password: '',
				showText: true,
				second: 60,
				code: '',
				phone: ''
			};
		},
		methods: {
			getYZM() {
				if (this.phone == '' || this.phone.length < 11) {
					this.$u.toast('手机号码格式错误');
					return;
				}
				this.showText = false;
				var interval = setInterval(() => {
					let times = --this.second
					this.second = times < 10 ? '0' + times : times //小于10秒补 0
				}, 1000)
				setTimeout(() => {
					clearInterval(interval)
					this.second = 60
					this.showText = true
				}, 60000)
				this.$http('common.getYZM', {
					phone: this.phone
				}).then(res => {
					if (res.code == 200) {
						console.log(res.data)
					}
				}).catch(err => {

				})
			},
			submit() {
				if (this.phone == '') {
					uni.showToast({
						title: '请输入手机号',
						icon: 'error'
					});
					return;
				}
				if (this.code == '') {
					uni.showToast({
						title: '请输入验证码',
						icon: 'error'
					});
					return;
				}
				if (this.password == '') {
					uni.showToast({
						title: '请输入新密码',
						icon: 'error'
					});
					return;
				}
				this.$http('common.forgetPassword', {
					code: this.code,
					newPassword: this.password,
					phone: this.phone
				}).then(res => {
					if (res.code == 200) {
						uni.navigateTo({
							url: 'pages/login/login'
						})
					} else {
						this.$u.toast(res.msg);
					}
				}).catch(err => {})
			}
		},
	};
</script>

<style scoped lang="css">
	.send {
		color: #666;
	}

	/deep/.is-input-border {
		border: 0 none !important;
	}

	.uni-easyinput__placeholder-class {
		font-size: 28rpx;
	}

	.group_ipt input {
		font-size: 28rpx;
		line-height: 30rpx;
		padding-left: 35rpx;
	}

	.image_10 {
		width: 638rpx;
		height: 2rpx;
	}

	.image_8 {
		width: 34rpx;
		height: 34rpx;
	}

	.page {
		background-color: #ffffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group_3 {
		padding: 29rpx 50rpx 297rpx 56rpx;
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.image_7 {
		align-self: center;
		border-radius: 40rpx;
		/* box-shadow: 0px 8rpx 20rpx 0px #1d6aff1f; */
		width: 230rpx;
		height: 230rpx;
	}

	.group_4 {
		margin-top: 177rpx;
	}

	.button {
		margin-right: 6rpx;
		margin-top: 103rpx;
		padding: 19rpx 0 31rpx;
		background-color: #1d6aff;
		border-radius: 44rpx;
	}

	.group_6 {
		margin-top: 20rpx;
	}

	.image_13 {
		margin-left: 4.5rpx;
		margin-top: 44rpx;
	}

	.group_9 {
		padding: 43rpx 0 42rpx;
	}

	.image_16 {
		margin-left: 4.5rpx;
	}

	.text_4 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.image_9 {
		margin-top: 8rpx;
	}

	.text {
		margin-left: 28rpx;
		margin-bottom: 4rpx;
		color: #bfbfbf;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.image_11 {
		margin-left: 4rpx;
	}

	.group_7 {
		padding-top: 36rpx;
	}

	.text_2 {
		margin: 3rpx 0 7rpx;
		color: #1d6aff;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.image_14 {
		flex-shrink: 0;
		margin-top: 12rpx;
	}

	.text_3 {
		margin-left: 28rpx;
		color: #bfbfbf;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.image_12 {
		margin-top: 9rpx;
		flex-shrink: 0;
	}

	.text_1 {
		margin-left: 28rpx;
		margin-bottom: 5rpx;
		color: #bfbfbf;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}
</style>
